package io.renren.modules.deliveryman.service.impl;

import cn.hutool.core.util.StrUtil;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.deliveryman.dao.DeliveryManDao;
import io.renren.modules.deliveryman.entity.DeliveryManEntity;
import io.renren.modules.deliveryman.service.DeliveryManService;


@Service("deliveryManService")
public class DeliveryManServiceImpl extends ServiceImpl<DeliveryManDao, DeliveryManEntity> implements DeliveryManService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<DeliveryManEntity> deliveryManEntityQuery = new QueryWrapper<>();
        if (StrUtil.isNotBlank((String)params.get("name"))){
            deliveryManEntityQuery.lambda().like(DeliveryManEntity::getName,(String)params.get("name"));
        }
        deliveryManEntityQuery.lambda().orderByDesc(DeliveryManEntity::getCreatetime);
        IPage<DeliveryManEntity> page = this.page(
                new Query<DeliveryManEntity>().getPage(params),
                deliveryManEntityQuery
        );

        return new PageUtils(page);
    }

}